# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=checkov
pkgver=3.2.495.r1.g91be04408
pkgrel=1
pkgdesc='Prevent cloud misconfigurations and find vulnerabilities during build-time in infrastructure as code, container images and open source packages.'
groups=('blackarch' 'blackarch-code-audit')
arch=('any')
url='https://github.com/bridgecrewio/checkov'
license=('Apache')
depends=('python' 'python-virtualenv')
makedepends=('git')
source=("git+https://github.com/bridgecrewio/$pkgname.git")
sha512sums=('SKIP')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE Pipfile Pipfile.lock

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
source venv/bin/activate
exec python bin/$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

